﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Softserve.Pottery.Infrastructure;
using Softserve.Pottery.Store.Domains;

namespace Pottery.Frontend.ViewModels
{
    public class ProductsViewModel : IAssignable
    {
        #region IAssignable implemintation
        
        public void AssignTo(object obj)
        {
            if (obj == null)
                throw new ArgumentNullException();

            if (obj is ProductsViewModel)
            {
                ProductsViewModel model = obj as ProductsViewModel;
                model.Products = Products;
                model.Catalogs = Catalogs;
            }

            throw new NotSupportedException();
        }

        #endregion

        #region Public logic

        public static ProductsViewModel FromDomainModel(IEnumerable<Product> products, IEnumerable<Catalog> catalogs)
        {
            if ((products == null) || (catalogs == null))
                return null;

            return new ProductsViewModel
            {
                Products = products,
                Catalogs = catalogs
            };
        }

        #endregion
        
        #region Properties

        public IEnumerable<Product> Products { get; set; }
        public IEnumerable<Catalog> Catalogs { get; set; }

        #endregion
    }
}